<!DOCTYPE html>
<html>

<head>
    <link rel="stylesheet" href="../../css/common/reset.css">
    <link rel="stylesheet" href="../../css/member.css">
</head>

<body style="background: #fff;">
    <!--列表 class="wechatPopup "-->
    <form action="?" class="layui-form">
        <ul>
            <li>
                <p class="fl labelText">设置密码：</p>
                <p class="fl">
                    <input type="password" placeholder="请输入新密码" required lay-verify="pwd" id="pwd">
                </p>
            </li>
            <li>
                <p class="fl labelText">确认密码：</p>
                <p class="fl">
                    <input type="password" placeholder="请输入确认新密码" required lay-verify="repwd" id="repwd">
                </p>
            </li>
            <!-- <li>
                <p class="fl labelText">身份验证：</p>
                <p class="fl">
                    <input type="password" placeholder="请输入支付密码" required>
                </p>
            </li> -->
            <li>
                <input type="submit" value="确定提交" class="btn sureBtn" lay-submit="" lay-filter="editPlay">
                <input type="button" value="返回修改" class="btn editBtn">
            </li>
        </ul>
    </form>
    <script src="../../js/jquery.min.js"></script>
    <script src="../../js/jquery.cookie.js"></script>
    <script src="../../layui/layui.js"></script>
    <script>
        layui.use(['form'], function () {
            var form = layui.form;
            form.verify({
                pass: [
                    /^[\S]{6,12}$/
                    , '密码必须6到12位，且不能出现空格'
                ],
                repwd: function (value) {
                    //获取密码
                    var pwd = $("#pwd").val();
                    if (!new RegExp(pwd).test(value)) {
                        return '两次输入的密码不一致';
                    }
                }
            });
            //监听提交
            form.on('submit(editPlay)', function (data) {
                var pwd = $('#pwd').val();
                var mid = $.cookie('id');
                var JdateJson = {
                    "payPassword": pwd,
                    "id": mid
                }
                $.ajax({
                    url: "http://47.92.174.143:8888/v1/client/merchants",
                    type: 'put',
                    dataType: 'json',
                    contentType: "application/json;charset=utf-8",
                    data: JSON.stringify(JdateJson),
                    success: function (data) {
                        var _Success = data.code;
                        if (_Success == 200) {
                            layer.msg("修改成功");
                            // return;
                            var index = parent.layer.getFrameIndex(window.name);
                            setTimeout(function () {
                                parent.layer.close(index);//关闭弹出层
                                parent.location.reload();//更新父级页面（提示：如果需要跳转到其它页面见下文）
                            }, 2000);
                            // location.href = "/";
                        } else {
                            layer.msg(data.data);
                        }
                    }
                })
                //防止页面跳转
                return false;
            });
        });
    </script>
</body>

</html>